﻿@model BrnShop.Web.Mobile.Models.ProductModel
@{
    Layout = null;
}
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>@Model.ProductInfo.Name-@{@WorkContext.ShopConfig.SiteTitle}触屏版</title>
    @Html.Raw(WorkContext.ShopConfig.SEOKeyword)
    @Html.Raw(WorkContext.ShopConfig.SEODescription)
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="@{@WorkContext.CSSCDN}/mobile/themes/default/css/base.css" rel="stylesheet" type="text/css">
    <link href="@{@WorkContext.CSSCDN}/mobile/themes/default/css/content.css" rel="stylesheet" type="text/css">
    <script src="@{@WorkContext.ScriptCDN}/mobile/scripts/utils.js" type="text/javascript"></script>
    <script src="@{@WorkContext.ScriptCDN}/mobile/scripts/common.js" type="text/javascript"></script>
    <script src="@{@WorkContext.ScriptCDN}/mobile/scripts/product.js" type="text/javascript"></script>
    <script type="text/javascript">
        uid = @WorkContext.Uid;
        pid = @Model.Pid;
        isGuestSC = @WorkContext.ShopConfig.IsGuestSC;
    </script>
</head>

<body>
<header>
  <div class="new-header">
    <a href="javascript:pageBack()" class="new-a-back"><span>返回</span></a>
    <h2>商品介绍</h2>
    <a href="javascript:navSH()" class="new-a-brn"><span>BRN键</span></a> 
  </div>
  <div class="new-brn-tab" id="nav" style=" display:none;">
    <div class="new-tbl-type"> 
    <a href="@Url.Action("index", "home")" class="new-tbl-cell"><span class="icon">首页</span><p style="color:#6e6e6e;">首页</p></a> 
    <a href="@Url.Action("list", "category")" class="new-tbl-cell"><span class="icon2 on">分类搜索</span><p style="color:#6e6e6e;" class="on">分类搜索</p></a> 
    <a href="@Url.Action("index", "cart")" class="new-tbl-cell"><span class="icon3">购物车</span><p style="color:#6e6e6e;">购物车</p></a> 
    <a href="@Url.Action("index", "ucenter")" class="new-tbl-cell"><span class="icon4 on">个人中心</span><p style="color:#6e6e6e;" class="on">个人中心</p></a> 
    </div>
  </div>
</header>

<div class="conHeader">
<div class="sliderBox">
    <ul class="slider" id="pImgList">
    @foreach (ProductImageInfo info in Model.ProductImageList)
    {
    <li><img src="@{@WorkContext.ImageCDN}/upload/product/show/thumb300_300/@info.ShowImg" width="320"></li>
    }
    </ul>
    <div class="bannerBt" id="pImgTabList">
    @for (int i = 0; i < Model.ProductImageList.Count; i++)
    {
      <span class="point @if(i==0){<text>hot</text>}"></span> 
    }
    </div>
</div>
  <script type="text/javascript">
      //商品图片滚动
      var liList = document.getElementById("pImgList").getElementsByTagName("li");
      var spanList = document.getElementById("pImgTabList").getElementsByTagName("span");
      var pImgIndex = 0;
      var pImgCount = @Model.ProductImageList.Count;
      if(pImgCount > 1) {
          window.setInterval(function () {
              if (pImgIndex == (pImgCount - 1)) {
                  pImgIndex = 0;
              }
              else {
                  pImgIndex += 1;
              }
              for (var i = 0; i < liList.length; i++) {
                  liList[i].style.display = "none";
              }
              for (var i = 0; i < spanList.length; i++) {
                  spanList[i].className = "point";
              }
              liList[pImgIndex].style.display = "block";
              spanList[pImgIndex].className = "point hot";
          }, 3000)
      }
  </script>

<div class="detail-price">
<span class="text" id="price">¥@Model.DiscountPrice</span>
<a class="btn-sc" href="javascript:void(0)" onclick="addToFavorite(@Model.Pid)"><span></span></a>
</div>
</div>

<div class="conBox"><div class="info2"><p class="text1">@Model.ProductInfo.Name</p></div></div>
<div class="h15"></div>
<script type="text/javascript">
    function promotionDesSH() {
        if (document.getElementById("promotionDes").style.display == "none") {
            document.getElementById("promotionDes").style.display = "block"
        }
        else {
            document.getElementById("promotionDes").style.display = "none"
        }
    }
</script>
<div class="conBox">
<div class="info">
    <a href="javascript:promotionDesSH()">
        <span class="text">促销信息</span>
        @if (Model.SinglePromotionInfo != null)
        { 
        if (Model.SinglePromotionInfo.PayCredits > 0)
        { 
        <i class="icon-bg02">赠积分</i>
        }
        if (Model.SinglePromotionInfo.CouponTypeId > 0)
        { 
        <i class="icon-bg02">赠劵</i>
        }
        }
        @if (Model.BuySendPromotionList != null && Model.BuySendPromotionList.Count > 0)
        { 
        <i class="icon-bg02">买几送几</i>
        }
        @if (Model.GiftPromotionInfo != null && Model.ExtGiftList.Count > 0)
        { 
        <i class="icon-bg02">赠品</i>
        }
        @if (Model.FullSendPromotionInfo != null)
        { 
        <i class="icon-bg02">加价购</i>
        }
        @if (Model.FullCutPromotionInfo != null)
        { 
        <i class="icon-bg02">满减</i>
        }
        @if (Model.SuitProductList != null && Model.SuitProductList.Count > 0)
        { 
        <i class="icon-bg02">套装</i>
        }
    </a>
    <span class="icon-arr"></span>
</div>
<div class="info proCXBox" id="promotionDes" style=" display:none;">
<ul class="proCX_list">
        @if (Model.SinglePromotionInfo != null)
        { 
        if (Model.SinglePromotionInfo.PayCredits > 0)
        { 
        <li><span class="col02"><em class="icon-bg02">赠积分</em><span class="txt01">赠 @Model.SinglePromotionInfo.PayCredits 积分</span></span></li>
        }
        if (Model.SinglePromotionInfo.CouponTypeId > 0)
        { 
        <li><span class="col02"><em class="icon-bg02">赠劵</em><span class="txt01">赠送优惠劵劵</span></span></li>
        }
        }
        @if (Model.BuySendPromotionList != null && Model.BuySendPromotionList.Count > 0)
        { 
        <li><span class="col02"><em class="icon-bg02">买几送几</em><span class="txt01">
        @foreach (BuySendPromotionInfo info in Model.BuySendPromotionList)
        {
             @:买 @info.BuyCount 送 @info.SendCount
        }
        </span></span></li>
        }
        @if (Model.GiftPromotionInfo != null && Model.ExtGiftList.Count > 0)
        { 
            foreach (ExtGiftInfo info in Model.ExtGiftList)
            {
            <li><span class="col02"><em class="icon-bg02">赠品</em><span class="txt01">@info.Name</span></span></li>
            }
        }
        @if (Model.FullSendPromotionInfo != null)
        { 
            <li><span class="col02"><em class="icon-bg02">加价购</em><span class="txt01">满 @Model.FullSendPromotionInfo.LimitMoney 元，再加 @Model.FullSendPromotionInfo.AddMoney 元，获取赠品</span></span></li>
        }
        @if (Model.FullCutPromotionInfo != null)
        { 
            <li><span class="col02"><em class="icon-bg02">满减</em><span class="txt01">
                满 @Model.FullCutPromotionInfo.LimitMoney1 元减 @Model.FullCutPromotionInfo.CutMoney1 
            @if (Model.FullCutPromotionInfo.LimitMoney2 > 0)
            {
                @:满 @Model.FullCutPromotionInfo.LimitMoney2 元减 @Model.FullCutPromotionInfo.CutMoney2 
            }
            @if (Model.FullCutPromotionInfo.LimitMoney3 > 0)
            {
                @:满 @Model.FullCutPromotionInfo.LimitMoney3 元减 @Model.FullCutPromotionInfo.CutMoney3 
            }
            </span></span></li>
        }
        @if (Model.SuitProductList != null && Model.SuitProductList.Count > 0)
        { 
        <li><span class="col02"><em class="icon-bg02">优惠套装</em>
        @{
            int maxSuitDiscount = 0;
            }
        @foreach (KeyValuePair<SuitPromotionInfo, List<ExtSuitProductInfo>> pair in Model.SuitProductList)
        {
            int tempMaxSuitDiscount = 0;
            foreach (ExtSuitProductInfo info in pair.Value)
            {
                tempMaxSuitDiscount += info.Number * info.Discount;
            }
            if (tempMaxSuitDiscount > maxSuitDiscount)
            {
                maxSuitDiscount = tempMaxSuitDiscount; 
            }
        }
        <span class="txt01">最高省 @maxSuitDiscount 元</span>
        </span>
        <span class="txt-amount"><a href="#">共 @Model.SuitProductList.Count 款</a></span></li>
        }
</ul>
    @if (Model.SuitProductList != null && Model.SuitProductList.Count > 0)
    { 
    <div class="suit-check-slide">
        <ul class="list-suit">
        @for (int i = 1; i <= Model.SuitProductList.Count; i++)
        {
          <li class="icon-suit"><a href="@Url.Action("productsuitlist", new RouteValueDictionary { { "pid", Model.Pid } })"><span class="val-mid">套装@{@i}</span></a></li>
        List<ExtSuitProductInfo> extSuitProductList = Model.SuitProductList[i - 1].Value;
        foreach (ExtSuitProductInfo info in extSuitProductList)
        {
          <li class="list-suit-item"><a href="@Url.Action("productsuitlist", new RouteValueDictionary { { "pid", Model.Pid } })" class="box-img-link"><div class="p-img"><img width="70" height="70" src="@{@WorkContext.ImageCDN}/upload/product/show/thumb60_60/@info.ShowImg"></div></a></li>
        }
        }
        </ul>
    </div>
    }
</div>
</div>
<div class="h15"></div>
<div class="conBox">
@foreach (ExtProductSKUItemInfo info in Model.ProductSKUList.FindAll(x => x.Pid == Model.Pid))
{
<div class="proInfo on"><div class="itmeP"><div class="dt">@info.AttrName：</div><div class="dd">@if (info.IsInput == 0)
                                                                        {@info.AttrValue}
                                                                        else
                                                                        {@info.InputValue}</div></div></div>
}
<div class="infoSelect">

    @if (Model.ProductSKUList != null && Model.ProductSKUList.Count > 0)
    {
        int attrLayer = 0;
        List<ExtProductSKUItemInfo> currentProductSKUItemList = Model.ProductSKUList.FindAll(x => x.Pid == Model.Pid);
        List<KeyValuePair<int, ExtProductSKUItemInfo>> skuProductList = new List<KeyValuePair<int, ExtProductSKUItemInfo>>();
        foreach (IGrouping<int, ExtProductSKUItemInfo> info in Model.ProductSKUList.GroupBy(x => x.Pid, x => x))
        {
            int attrValueIdKey = 1;
            foreach (var item in info)
            {
                attrValueIdKey *= item.AttrValueId;
            }
            skuProductList.Add(new KeyValuePair<int, ExtProductSKUItemInfo>(attrValueIdKey, info.First<ExtProductSKUItemInfo>()));
        }
        List<ExtProductSKUItemInfo> attrList = new List<ExtProductSKUItemInfo>();
        foreach (ExtProductSKUItemInfo info in Model.ProductSKUList)
        {
            if (attrList.Find(x => x.AttrId == info.AttrId) == null)
            {
                attrList.Add(info);
            }
        }
        foreach (ExtProductSKUItemInfo info in attrList)
        {
            @:<div class="itmeP"><div class="dt">@info.AttrName：</div><div class="dd">
            List<ExtProductSKUItemInfo> attrValueList = new List<ExtProductSKUItemInfo>();
            foreach (ExtProductSKUItemInfo attrValue in Model.ProductSKUList)
            {
                if (attrValue.AttrId == info.AttrId && attrValueList.Find(x => x.AttrValueId == attrValue.AttrValueId) == null)
                {
                    attrValueList.Add(attrValue);
                }
            }

            foreach (ExtProductSKUItemInfo attrValue in attrValueList)
            {
                int attrValueIdKey = 1;
                for (int i = 0; i < currentProductSKUItemList.Count; i++)
                {
                    if (attrLayer != i)
                    {
                        attrValueIdKey *= currentProductSKUItemList[i].AttrValueId;
                    }
                    else
                    {
                        attrValueIdKey *= attrValue.AttrValueId;
                    }
                }
                KeyValuePair<int, ExtProductSKUItemInfo> skuProduct = skuProductList.Find(x => x.Key == attrValueIdKey);
                if (skuProduct.Value == null)
                {
                    <a href="#" class="gayBt">@if (attrValue.IsInput == 0)
                                              { @attrValue.AttrValue }
                                              else
                                              { @attrValue.InputValue }</a>
                }
                else
                {
                    <a href="@Url.Action("product", new RouteValueDictionary { { "pid", skuProduct.Value.Pid } })" class="@if (skuProduct.Value.Pid == Model.Pid)
                                                                                                                          { <text>redBt</text> }
                                                                                                                          else
                                                                                                                          { <text>gayBt</text>}">@if (attrValue.IsInput == 0)
                                                                                                                                                 { @attrValue.AttrValue }
                                                                                                                                                 else
                                                                                                                                                 { @attrValue.InputValue }</a>
                }
            }
            @:</div></div>
            attrLayer++;
        }
    }
    
<div class="itmeP">
<div class="dt">数量：</div>
<div class="dd">
<a href="javascript:void(0);" onclick="cutProductCount()" class="gayBt">-</a>
<a href="javascript:void(0);" class="gayBt" style="padding:4px 0px;"><input style=" width:60px; text-align:center;border:0; background:none;" id="buyCount" name="buyCount" value="1" /></a>
<a href="javascript:void(0);" onclick="addProuctCount()" class="gayBt">+</a>
</div>
</div>

</div>
</div>
<div class="h15"></div>
<div class="conBox">
<div class="info"><a href="@Url.Action("productdetails", new RouteValueDictionary { { "pid", Model.Pid } })"><span class="text">商品信息</span></a><span class="icon-arr"></span></div>
<div class="info"><a href="@Url.Action("productreviewlist", new RouteValueDictionary { { "pid", Model.Pid } })"><span class="text">商品评价</span><span class="text-fr"><em>@Model.ProductInfo.ReviewCount</em>人评价<em>@Html.Raw(Model.ProductInfo.GetStarLevel().ToString())%</em>好评</span></a><span class="icon-arr"></span></div>
<div class="tbl-type"><span class="tbl-cell"><a href="@Url.Action("productconsultlist", new RouteValueDictionary { { "pid", Model.Pid } })" class="btn-ser" id="consultations"><span class="icon"></span>购买咨询</a></span></div>
</div>

<div id="addResult1" class="bg" style="display:none;position:absolute;left:0px;top:0px;background-color:rgb(13, 13, 13);filter:alpha(opacity=60);opacity: 0.6;width:100%;height:100%;z-index:8888;"></div>
<div id="addResult2" class="cartTip" style="display:none;">
  <div class="ico-succ"><span class="att-succ">添加成功！</span><span class="cart-succ">商品已成功加入购物车</span></div>
  <div class="cp-lnk"><a href="javascript:void(0);" onclick="document.getElementById('addResult1').style.display = 'none';document.getElementById('addResult2').style.display = 'none';">再逛逛</a><a href="@Url.Action("index", "cart")"><span class="bar"></span>去购物车</a></div>
</div>

@if (Model.RelateProductList.Count > 0)
{
<div class="img-list">
  <p>也许您还喜欢：</p>
  <div class="img-sild">
    <div>
      <div class="tbl-type"> 
        @foreach (PartProductInfo info in Model.RelateProductList)
        {
          <a class="tbl-cell" href="@Url.Action("product", new RouteValueDictionary { { "pid", info.Pid } })"><div class="pro-img"> <span class="img"><img src="@{@WorkContext.ImageCDN}/upload/product/show/thumb100_100/@info.ShowImg" width="85" height="85" alt="img"></span><span class="pro-title">@info.Name</span><span class="pro-price">¥@info.ShopPrice</span></div></a>
        }
      </div>
    </div>
  </div>
</div>
}

<div class="footerBar">
  <div><a href="javascript:void(0)" onclick="addProductToCart(@Model.Pid, document.getElementById('buyCount').value, 0)" class="buy"><span></span>立即购买</a> </div>
  <div><a href="javascript:void(0)" onclick="addProductToCart(@Model.Pid, document.getElementById('buyCount').value, 1)" class="cart"><span></span>加入购物车</a> </div>
</div>

<div class="viewport">
  <footer>
    <div class="footerTop">
      @if (WorkContext.Uid < 1)
      {
      <div class="left"><a href="@Url.Action("login", "account", new RouteValueDictionary { { "returnUrl", WorkContext.Url } })">登录</a> | <a href="@Url.Action("register", "account")">注册</a></div>
      }
      else
      {
        <div class="left"><a href="@Url.Action("index", "ucenter")">@WorkContext.NickName</a> | <a href="@Url.Action("logout", "account")">退出</a></div>   
      }
      <div class="right"><a href="#top">回到顶部 </a></div>
      <div class="clear"></div>
    </div>
    <div class="footerCon"><a href="@Url.Action("index", "home")" class="hot">触屏版</a><a href="/">电脑版</a></div>
    <div class="copyright" align="center">www.brnshop.com </div>
  </footer>
</div>
<script type="text/javascript">
    //高度需要计算 .bg的高度 = 当前body的高度
    document.getElementById("addResult1").style.height = document.body.scrollHeight + "px";
</script>
@Html.Raw(WorkContext.ShopConfig.Script)
</body>
</html>
